/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Silvia
 */
@Entity
@Table(name = "breed")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Breed.findAll", query = "SELECT b FROM Breed b"),
    @NamedQuery(name = "Breed.findByIdBreed", query = "SELECT b FROM Breed b WHERE b.idBreed = :idBreed"),
    @NamedQuery(name = "Breed.findByBreedName", query = "SELECT b FROM Breed b WHERE b.breedName = :breedName")})
public class Breed implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idBreed")
    private Integer idBreed;
    @Size(max = 45)
    @Column(name = "breedName")
    private String breedName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "breedidBreed")
    private Collection<Animal> animalCollection;

    public Breed() {
    }

    public Breed(Integer idBreed) {
        this.idBreed = idBreed;
    }

    public Integer getIdBreed() {
        return idBreed;
    }

    public void setIdBreed(Integer idBreed) {
        this.idBreed = idBreed;
    }

    public String getBreedName() {
        return breedName;
    }

    public void setBreedName(String breedName) {
        this.breedName = breedName;
    }

    @XmlTransient
    public Collection<Animal> getAnimalCollection() {
        return animalCollection;
    }

    public void setAnimalCollection(Collection<Animal> animalCollection) {
        this.animalCollection = animalCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idBreed != null ? idBreed.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Breed)) {
            return false;
        }
        Breed other = (Breed) object;
        if ((this.idBreed == null && other.idBreed != null) || (this.idBreed != null && !this.idBreed.equals(other.idBreed))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Breed[ idBreed=" + idBreed + " ]";
    }
    
}
